﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web;

/// <summary>
///CGeneral 的摘要说明
/// </summary>
public class CGeneral
{
    public static void GoToErrorPage(HttpResponse R, string type)
    {
        R.Redirect("Error.aspx?type=" + type);
    }

    public static void GoToErrorPage(HttpResponse R, string type, string title)
    {
        R.Redirect("Error.aspx?type=" + type + "&title=" + title);
    }
	
    public static void  GoToErrorPage(HttpResponse R,string type,string title,string content)
    {
        R.Redirect("Error.aspx?type=" + type + "&title=" + title + "&content=" + content);
    }

    public static void GoToErrorPage(HttpResponse R, string type, string title, string content, string go)
    {
        R.Redirect("Error.aspx?type=" + type + "&title=" + title + "&content=" + content + "&goto=" + go);
    }
    public static void CheckLogin(HttpRequest Request,System.Web.SessionState.HttpSessionState Session)
    {
        if (Session["username"] == null)
        {
            if (Request.Cookies["user"] != null)
                if (Request.Cookies["user"]["username"] != null && Request.Cookies["user"]["password"] != null)
                {
                    members m = Check.LoginCheck(Request.Cookies["user"]["username"], Request.Cookies["user"]["password"]);
                    //members m = null;
                    if (m != null)
                    {
                        Session["username"] = m.username;
                        Session["uid"] = m.uid;
                        Session["gid"] = m.gid;
                        Session["nickname"] = m.nickname;
                        Session["LoginTime"] = DateTime.Now;
                    }
                }
        }

        if (Session["username"] == null)
            Session["gid"] = 2;
    }



}